#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <set>
#include <vector>


using namespace std;

int main() {
  int i,j ,k;
  long long N, R;
  int casos = 0;
#define MM 20101
  long long prec[MM];
  prec[0] = 0;
  prec[1] = 0;
  prec[2] = 1;
  for (long long v = 3; v < MM; ++v)
    prec[v] = prec[v-1] + v-1;
  while (cin >> N >> R) {
    if(!N) break;
    vector<double> vec;
    long long res = 0;
    casos++;
    for (i = 0; i < N; ++i) {
      double d; cin >> d; vec.push_back(d);
    }
      printf("Case %d: ", casos);
    if (N <3) {
      printf("0\n"); continue;
    } 
    sort(vec.begin(), vec.end());
    for (i = 0; i < N; ++i) vec.push_back(vec[i]+360.);

    // unimos el primero..
    int ind = 1;
  //  for (i = 0; i < vec.size(); ++i) cout << vec[i] << "  " ; cout << endl;
    for (i = 0; i < N; ++i) {
      while (ind < i + N && vec[ind]-vec[i] <= 180. + 1e-10) ind++;
//      cout << i << "  " << ind << "  " << ind-i-2 << endl;
      if (ind > i+1) res += prec[ind-i-1];
    }
 //   cout << res << endl;
    res = (N*(N-1LL)*(N-2LL))/6LL - res;
    cout << res << endl;
  } return 0; 
}
